<%@ page contentType="text/html;charset=UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<title>权限系统注册管理</title>
		<%@ include file="/common/meta.jsp" %>
    <%@ include file="/common/import.jsp" %>
	<%@ include file="uct-import.jsp" %>

		<script>

$(function() {
	$('#sysList').datagrid( {
		title : '权限系统注册列表',
		url : '${ctx}/uct/sys/sys!data.action',
		loadMsg : '数据载入中，请稍后……',
		nowrap : false,
		collapsible : false,
		fitColumns : true,
		pagination : true,
		singleSelect : true,
		rownumbers : true,
		remoteSort : false,
		pageList : [10,15,20,50],
		idField : 'sysId',
		frozenColumns : [ [ {
			title : '中文名称',
			field : 'sysCname',
			width : 200,
			formatter : function(value) {
				return '<span style="color:blue">' + value + '</span>';
			}
		} ] ],
		columns : [ [ {
			field : 'sysEname',
			title : '英文标识',
			width : 100,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'orderNum',
			title : '排序',
			width : 100,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'createTime',
			title : '创建时间',
			width : 100,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			},
			formatter : function(value) {
				return getFormatDateByLong(value,"yyyy-MM-dd hh:mm:ss");
			}
		}, {
			field : 'createUser',
			title : '创建人',
			width : 100
		}] ],

		toolbar : [ {
			text : '增加',
			iconCls : 'icon-add',
			handler : function() {
				addSys();
			}

		}, '-', {
			text : '修改',
			iconCls : 'icon-edit',
			handler : function() {
				editSys();
			}
		}, '-', {
			text : '删除',
			iconCls : 'icon-cut',
			handler : function() {
				delSys();
			}
		}, '-',

		{
			text : '刷新',
			iconCls : 'icon-reload',
			handler : function() {
				reload('');
			}
		} ],
		onDblClickRow:function(row){
			editSys();
		}
	});
});

function delSys() {
	var node = getSelected();
	if (node) {
		$.messager.confirm('确认', '删除系统会对应删除与之对应的权限及资源,您确定要删除:<font color="red">' + node.sysCname + '</font> ？',
				function(r) {
					if (r) {
						$.ajax( {
							type : "post",
							url : "${ctx}/uct/sys/del.action?id="+ node.sysId,
							success : function(data, textStatus) {
								var result = jQuery.parseJSON(data);
								if(result.flag=="T"){
									$.messager.alert('结果', '操作成功', 'info');	
									var rowIndex = $('#sysList').datagrid('getRowIndex',node);								
									$('#sysList').datagrid('deleteRow', rowIndex);
									reload();
								}else{
									$.messager.alert('提交结果', result.msg, 'error');
								}
							}
						});
					}
				});
	}

}

function editSys() {
	var node = getSelected();
	if (node) {
		$('#sysAddFrame').html('');
		var url = '${ctx}/uct/sys/edit.action?id=' + node.sysId;
		$('#sysAddFrame').attr("src", url);
		$('#sysAddWin').window('open');
	}
}

function editLock() {
	var node = getSelected();
	if (node) {
		var editLockUrl = '${ctx}/uct/core/lock-list!toData.action?sysId='+node.sysId;
		window.location.href=editLockUrl;
	}
}


function closeAddWin(){
	$('#sysAddWin').window('close');
}

function addSys() {
	$('#sysAddFrame').html('');
	var url = '${ctx}/uct/sys/add.action';
	$('#sysAddFrame').attr("src", url);
	$('#sysAddWin').window('open');

}

function getSelected() {
	var selected = $('#sysList').datagrid('getSelected');
	if (selected) {
		return selected;
	} else {
		$.messager.alert('提示', '请选择要操作的数据', 'info');
	}
}

function reload(){
		$('#sysList').datagrid('reload');
}
		
	function lockQuery(){					
	    var queryParams = $('#sysList').datagrid('options').queryParams;
	      queryParams.sysCname = $('#sysCname').val();
	      queryParams.sysEname = $('#sysEname').val();
	      var options = $('#sysList').datagrid('getPager').data("pagination").options;  
	        options.pageNumber=1;  
	        options.total=0;  
	        options.pageSize=10; 
	      reload(); 
	  }
	function clearQuery(){					
	    $('#sysCname').val('');
	    $('#sysEname').val('');
	    lockQuery(); 
	  }
	  
			
	</script>
	</head>

	<body>
		<table class="planel-body">
			<tr>
				<td>中文名称</td>
				<td>
					<input name="sysCname" id="sysCname" value=""/>
				</td>
				<td>英文标识</td>
				<td>
					<input name="sysEname" id="sysEname" value=""/>
				</td>
				<td>
					<a class="easyui-linkbutton" iconCls="icon-search"
						onclick="lockQuery();">查询</a>
					<a class="easyui-linkbutton" iconCls="" onclick="clearQuery();">清空</a>
				</td>
			</tr>
		</table>


		<table id="sysList"></table>

		<div id="sysAddWin" class="easyui-window" title="权限系统注册信息"
			style="padding: 5px; width: 600px; height: 300px;overflow: hidden;"
			iconCls="icon-search" closed="true" maximizable="false"
			minimizable="false" collapsible="false" >
			<iframe frameborder="0" id="sysAddFrame" height="100%" width="100%"
				scrolling="yes" frameborder="0"></iframe>
		</div>

	</body>
</html>